#ifndef UHM_UTIL_STREAM_HXX
#define UHM_UTIL_STREAM_HXX


/*! The header defines the interfaces for in-out stream.
 */


namespace uhm {

  template<class T_> std::ostream& operator<<(std::ostream& os, 
                                              const std::auto_ptr<T_>& p) {
    return os;
  }
  
  std::istream& read_to_endl(std::istream& in, std::string& str);
  std::istream& move_to_endl(std::istream& in);
  std::istream& skip_comment(std::istream& in);
  
  class Disp_ {
    friend std::ostream& operator<<(std::ostream& os, const Disp_& disp);
  private:
  protected:
  public:
    Disp_() { }
    virtual ~Disp_() { }
    
    virtual std::ostream& content(std::ostream& os) const {
      return (os << "[UHM] ");
    }
  };
}

/*! Implementation
 */
inline std::istream& uhm::read_to_endl(std::istream& in, 
                                       std::string& str) {
  Char_ c;
  while ( in.get(c) && c != '\n')
    str += c;
  return in;
}
inline std::istream& uhm::move_to_endl(std::istream& in) {
  Char_ c;
  while ( in.get(c) && c != '\n')
    ;
  return in;
}
inline std::istream& uhm::skip_comment(std::istream& in) {
  Char_ c;
  while( (in >> c) && c == '#')
    in >> move_to_endl;
  in.putback(c);
  return in;
}


#endif
